-
-
Notifications
You must be signed in to change notification settings - Fork 323
Fail when reading private key for selected certificate fails. #17659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Does not compile. |
8aefc36 to
2197502
Compare
2197502 to
6a5de82
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds validation to fail early when a private key cannot be read for a selected certificate during authentication, addressing issue #17657. The implementation introduces certificate validation in the login flow to prevent silent failures and improve error reporting.
Key Changes:
- Added
X509KeyManagerparameter toLoginService.validate()to enable private key validation - Implemented certificate validation logic in
KeychainLoginServicethat checks for private key availability and throwsLoginFailureExceptionif not found - Refactored jump host configuration to be set directly on the
Hostobject, simplifying the SSH connection flow
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| core/src/main/java/ch/cyberduck/core/LoginService.java | Updated validate() method signature to include X509KeyManager parameter; fixed typos in javadoc comments |
| core/src/main/java/ch/cyberduck/core/ssl/X509KeyManager.java | Added documentation for inherited getPrivateKey() method from parent interface |
| core/src/main/java/ch/cyberduck/core/KeychainLoginService.java | Added certificate private key validation logic; implemented recursive jumphost validation; removed default constructor |
| core/src/main/java/ch/cyberduck/core/Host.java | Added jumphost field with getter/setter methods to support jump host configuration |
| core/src/main/java/ch/cyberduck/core/LoginConnectionService.java | Integrated jump host configurator to set jumphost on bookmark before validation; pass X509KeyManager to validate method |
| ssh/src/main/java/ch/cyberduck/core/sftp/SFTPSession.java | Simplified jump host handling to use host.getJumphost() directly; removed OpenSSH configurator usage and credential management |
| cli/src/main/java/ch/cyberduck/cli/TerminalLoginService.java | Updated validate() method signature to match parent interface |
| core/src/test/java/ch/cyberduck/core/KeychainLoginServiceTest.java | Updated test calls to include DefaultX509KeyManager parameter |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if(options.certificate) { | ||
| final String alias = host.getCredentials().getCertificate(); | ||
| if(StringUtils.isNotBlank(alias)) { | ||
| if(keys != null) { | ||
| if(null == keys.getPrivateKey(alias)) { | ||
| log.warn("No private key found for alias {} in keychain", alias); | ||
| throw new LoginFailureException(LocaleFactory.localizedString("Provide additional login credentials", "Credentials")); | ||
| } | ||
| } | ||
| } | ||
| } |
Copilot
AI
Dec 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new certificate validation logic (lines 95-105) lacks test coverage. This is a critical code path that validates private key availability for certificate-based authentication and throws a LoginFailureException when validation fails. Consider adding test cases that cover:
- Successful validation when a valid private key exists for the given alias
- Failure scenario when
getPrivateKey()returns null - Edge case when
keysparameter is null - Edge case when alias is blank/null
Fix #17657. Refactor changes for #13936.